<el-dialog id="formCollect" title="收藏" :visible.sync="dialogCollectVisible" width="600px" v-cloak >
    <#--<el-scrollbar class="ms-scrollbar" style="height: 100%;">-->
        <el-form ref="collectForm" :model="collectForm" :rules="collectRules" size="mini" label-width="120px" >
            <el-form-item  label="选择收藏夹:" prop="starFolderId">
                <el-select v-model="collectForm.starFolderId"
                           :style="{width: '100%'}"
                           filterable
                           :disabled="false"
                           placeholder="请选择">
                    <el-option v-for='item in collectDirOptions'   :key="item.id" :value="item.id"
                               :label="item.name"></el-option>
                </el-select>
            </el-form-item>
            <#--<el-form-item  label="是否监控:" prop="watched">-->
                <#--<el-radio-group v-model="collectForm.watched">-->
                    <#--<el-radio :label="true">监控</el-radio>-->
                    <#--<el-radio :label="false">不监控</el-radio>-->
                <#--</el-radio-group>-->
            <#--</el-form-item>-->
            <#--<el-form-item  label="是否通知:" prop="announced">-->
            <#--<el-radio-group v-model="collectForm.announced">-->
            <#--<el-radio :label="true">通知</el-radio>-->
            <#--<el-radio :label="false">不通知</el-radio>-->
            <#--</el-radio-group>-->
            <#--</el-form-item>-->
            <#--<el-form-item  label="通知方式:" prop="announcementType">-->
                <#--<el-checkbox-group v-model="collectForm.announcementType">-->
                    <#--<el-checkbox label="SYS">系统通知</el-checkbox>-->
                    <#--<el-checkbox label="SMS">短信</el-checkbox>-->
                    <#--<el-checkbox label="EMAIL">邮箱</el-checkbox>-->
                <#--</el-checkbox-group>-->
                <#--<span style="color:red">* </span><span>{{noticeSelectTips}}</span>-->
            <#--</el-form-item>-->
        </el-form>
    <#--</el-scrollbar>-->
    <div slot="footer">
        <el-button size="mini" @click="dialogCollectVisible = false">取 消</el-button>
        <el-button size="mini" type="primary" @click="collectConfirm()">确 认</el-button>
    </div>
</el-dialog>
<script>
    var formCollect = new Vue({
        el: '#formCollect',
        data: function () {
            return {
                collectDirOptions:[],
                collectForm: {
                    id:'',
                    // userId:[],
                    // announcementType:[],
                    starFolderId:''
                },
                collectRules: {
                    // 申请说明
                    starFolderId: [ { "required": true, "message": "请选择收藏夹",  trigger: 'blur'}],
                },
                dialogCollectVisible:false,
                noticeSelectTips:"若用户未绑定手机号或邮箱，默认发送系统通知。",
            };
        },
        watch: {
        },
        computed: {},
        methods: {
            showCollectDialog: function(row){
                this.getCcollectionDirData();
                this.collectForm={ fileId:'', starFolderId:''};
                this.dialogCollectVisible=true;
                this.$nextTick(function () {
                    this.$refs.collectForm.clearValidate();
                });
                this.collectForm.fileId=row[0].id;
            },
            //获取收藏夹
            getCcollectionDirData:function () {
                var that = this;
                ms.http.get(ms.manager + "/collection/dir.do").then(function (res) {
                    if(res.code == 200){
                        that.collectDirOptions = res.data;
                    }
                });
            },
            collectConfirm:function(){
                var that = this;
                that.$refs.collectForm.validate(function (valid) {
                    if (valid) {
                        if(that.collectForm.starFolderId){
                            that.collectForm.starFolderId = parseInt(that.collectForm.starFolderId);
                        }
                        ms.http.post(ms.manager + "/cms/document/star.do", that.collectForm,{
                            headers: {
                                'Content-Type': 'application/json'
                            }
                        }).then(function (res) {
                            if(res.code===200){
                                that.$notify({
                                    type: 'success',
                                    message: "收藏成功"
                                });
                                //收藏成功，刷新列表
                                that.dialogCollectVisible = false;
                                indexVue.list();
                            }else{
                                that.$notify({
                                    type: 'error',
                                    message: "收藏失败"
                                });
                            }


                        }).catch(function (err) {
                            that.$notify({
                                type: 'error',
                                message: "收藏失败"
                            });
                        });
                    }
                })
            },
        },
        created: function () {}
    });
</script>
<style>

</style>
